#include "DropletColorTest/DropletColorTest.h"

DropletColorTest::DropletColorTest(ObjectPhysicsData *objPhysics) 
	: IDroplet(objPhysics) 
{ return; }

DropletColorTest::~DropletColorTest() { return; }

void DropletColorTest::DropletInit()
{
	ResetAllSystems();
	uint16_t dropletID;
	GetDropletID(&dropletID);

	srand(dropletID);

	SetRGB(0, 0, 255);
	colorSet = 0;
	northMoved = 0;
	southMoved = 0;
}

uint8_t DropletColorTest::getRandom(void)
{
	return static_cast<uint8_t>(256 * ((float)rand() / (float)RAND_MAX));
}

void DropletColorTest::DropletMainLoop()
{
	//uint8_t g = getRandom();
	//uint8_t b = getRandom();
	//uint8_t r = getRandom();
	//SetRGB(r, g, b);

	// Set a random color
	if(IsMoving() == 0)	// Not moving
	{
		if(colorSet == 0)
		{
			SetRGB(0, 0, 255);
			colorSet = 1;
		}

		
		if(getRandom() < 10)
		{
			uint8_t r = getRandom();
			uint8_t g = getRandom();
			uint8_t b = getRandom();
			SetRGB(r, g, b);
			Move(2, (r % 6) + 1);

			colorSet = 0;	 // Reset color after stop.
		}
	}

	// Move North, then South
	//if(northMoved == 0)
	//{
	//	Move(2, NORTH);
	//	SetRGB(255, 0, 0);
	//	northMoved = 1;
	//}

	//else if(IsMoving() == 0 && southMoved == 0)
	//{
	//	Move(2, SOUTH);
	//	SetRGB(0, 255, 0);
	//	southMoved = 1;
	//}

	//if(IsMoving() == 0 && northMoved > 0 && southMoved > 0 && colorSet == 0)
	//{
	//	SetRGB(0, 0, 255);
	//	colorSet = 1;
	//}
}